import request from '@/utils/request'

// 标签树

export function getTagTree(params) {
  return request({
    url: '/tag-trees',
    method: 'get',
    params
  })
}
export function delTagTree(id) {
  return request({
    url: `/tag-trees/${id}`,
    method: 'delete'
  })
}
export function createTagTree(data) {
  return request({
    url: `/tag-trees`,
    method: 'post',
    data
  })
}
export function getTagTreeDetail(data) {
  data = JSON.parse(JSON.stringify(data))
  const id = data.ids
  delete data.ids
  return request({
    url: `/tag-trees/${id}`,
    method: 'get',
    params: data
  })
}
// 单独标签
export function createTag(data) {
  return request({
    url: '/tags',
    method: 'post',
    data
  })
}
export function getTagList(params) {
  return request({
    url: '/tags',
    method: 'get',
    params
  })
}
export function addTags(type, id, tagsId, isCommApi = false) {
  const url = isCommApi ? `/customized-content/${id}/tags` : `/${type}/${id}/tags`
  const headers = isCommApi ? { ContentType: type } : {}
  return request({
    url,
    method: 'put',
    data: tagsId,
    headers
  })
}
// 标签树
export function getTagRelations(params) {
  return request({
    url: '/tag-relations',
    method: 'get',
    params
  })
}
export function delTagRelations(lId, rId) {
  return request({
    url: `/tag-relations/${lId}/${rId}`,
    method: 'delete'
  })
}
export function createTagRelations(data) {
  return request({
    url: '/tag-relations',
    method: 'post',
    data
  })
}
//  标签组
export function getTagGroups(params) {
  return request({
    url: '/tag-groups',
    method: 'get',
    params
  })
}

